



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class CoursesDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public CoursesDB()
        {
        }

        public CoursesDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<Courses> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<Courses> lstRet = new List<Courses>();

            string strQuery = " select " + strTop  + " * from dbo.[Courses]  " ;

            strWhere = GlobalThings.getWhereWithoutDeleted(strWhere);

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Courses obj = new Courses();
 if (dr["ID"] != DBNull.Value)
                    {
                        obj.ID = (System.Int64)dr["ID"];
                    }
                    else
                    {
                        obj.ID = -1;
                    } 
 if (dr["CourseNameEN"] != DBNull.Value)
                    {
                        obj.CourseNameEN = (System.String)dr["CourseNameEN"];
                    }
                    else
                    {
                        obj.CourseNameEN = "";
                    } 
 if (dr["CourseNameAR"] != DBNull.Value)
                    {
                        obj.CourseNameAR = (System.String)dr["CourseNameAR"];
                    }
                    else
                    {
                        obj.CourseNameAR = "";
                    } 
 if (dr["FolderID"] != DBNull.Value)
                    {
                        obj.FolderID = (System.Int64)dr["FolderID"];
                    }
                    else
                    {
                        obj.FolderID = -1;
                    } 
 if (dr["DateOfCreation"] != DBNull.Value)
                    {
                        obj.DateOfCreation = (System.DateTime?)dr["DateOfCreation"];
                    }
                    else
                    {
                        obj.DateOfCreation = null;
                    } 
 if (dr["TargetAR"] != DBNull.Value)
                    {
                        obj.TargetAR = (System.String)dr["TargetAR"];
                    }
                    else
                    {
                        obj.TargetAR = "";
                    } 
 if (dr["TargetEN"] != DBNull.Value)
                    {
                        obj.TargetEN = (System.String)dr["TargetEN"];
                    }
                    else
                    {
                        obj.TargetEN = "";
                    } 
 if (dr["OutlineAR"] != DBNull.Value)
                    {
                        obj.OutlineAR = (System.String)dr["OutlineAR"];
                    }
                    else
                    {
                        obj.OutlineAR = "";
                    } 
 if (dr["OutlineEN"] != DBNull.Value)
                    {
                        obj.OutlineEN = (System.String)dr["OutlineEN"];
                    }
                    else
                    {
                        obj.OutlineEN = "";
                    } 
 if (dr["Duration"] != DBNull.Value)
                    {
                        obj.Duration = (System.Int64?)dr["Duration"];
                    }
                    else
                    {
                        obj.Duration = null;
                    } 
 if (dr["Path"] != DBNull.Value)
                    {
                        obj.Path = (System.String)dr["Path"];
                    }
                    else
                    {
                        obj.Path = "";
                    } 
 if (dr["StatusID"] != DBNull.Value)
                    {
                        obj.StatusID = (System.Int64)dr["StatusID"];
                    }
                    else
                    {
                        obj.StatusID = -1;
                    } 
 if (dr["ObjectivesAR"] != DBNull.Value)
                    {
                        obj.ObjectivesAR = (System.String)dr["ObjectivesAR"];
                    }
                    else
                    {
                        obj.ObjectivesAR = null;
                    } 
 if (dr["ObjectivesEN"] != DBNull.Value)
                    {
                        obj.ObjectivesEN = (System.String)dr["ObjectivesEN"];
                    }
                    else
                    {
                        obj.ObjectivesEN = null;
                    } 
 if (dr["isCaptivate"] != DBNull.Value)
                    {
                        obj.isCaptivate = (System.Boolean)dr["isCaptivate"];
                    }
                    else
                    {
                        obj.isCaptivate = false;
                    } 
 if (dr["CaptivateFile"] != DBNull.Value)
                    {
                        obj.CaptivateFile = (System.String)dr["CaptivateFile"];
                    }
                    else
                    {
                        obj.CaptivateFile = "";
                    } 
 if (dr["LanguageID"] != DBNull.Value)
                    {
                        obj.LanguageID = (System.Int64)dr["LanguageID"];
                    }
                    else
                    {
                        obj.LanguageID = -1;
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<Courses> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Courses> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , Courses obj)
        {
            
            

                    DbParameter prmCourseNameEN = con.createParameter();
                    prmCourseNameEN.ParameterName = "@CourseNameEN";
                    prmCourseNameEN.DbType =DbType.String;
                    if (obj.CourseNameEN == null)
                    {
                        prmCourseNameEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCourseNameEN.Value = obj.CourseNameEN;
                    }
                

                    


                    DbParameter prmCourseNameAR = con.createParameter();
                    prmCourseNameAR.ParameterName = "@CourseNameAR";
                    prmCourseNameAR.DbType =DbType.String;
                    if (obj.CourseNameAR == null)
                    {
                        prmCourseNameAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCourseNameAR.Value = obj.CourseNameAR;
                    }
                

                    


                    DbParameter prmFolderID = con.createParameter();
                    prmFolderID.ParameterName = "@FolderID";
                    prmFolderID.DbType =DbType.Int64;
                    if (obj.FolderID == null)
                    {
                        prmFolderID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFolderID.Value = obj.FolderID;
                    }
                

                    


                    DbParameter prmDateOfCreation = con.createParameter();
                    prmDateOfCreation.ParameterName = "@DateOfCreation";
                    prmDateOfCreation.DbType =DbType.DateTime;
                    if (obj.DateOfCreation == null)
                    {
                        prmDateOfCreation.Value = DBNull.Value;
                    }
                    else
                    {
                        prmDateOfCreation.Value = obj.DateOfCreation;
                    }
                

                    


                    DbParameter prmTargetAR = con.createParameter();
                    prmTargetAR.ParameterName = "@TargetAR";
                    prmTargetAR.DbType =DbType.String;
                    if (obj.TargetAR == null)
                    {
                        prmTargetAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTargetAR.Value = obj.TargetAR;
                    }
                

                    


                    DbParameter prmTargetEN = con.createParameter();
                    prmTargetEN.ParameterName = "@TargetEN";
                    prmTargetEN.DbType =DbType.String;
                    if (obj.TargetEN == null)
                    {
                        prmTargetEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTargetEN.Value = obj.TargetEN;
                    }
                

                    


                    DbParameter prmOutlineAR = con.createParameter();
                    prmOutlineAR.ParameterName = "@OutlineAR";
                    prmOutlineAR.DbType =DbType.String;
                    if (obj.OutlineAR == null)
                    {
                        prmOutlineAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOutlineAR.Value = obj.OutlineAR;
                    }
                

                    


                    DbParameter prmOutlineEN = con.createParameter();
                    prmOutlineEN.ParameterName = "@OutlineEN";
                    prmOutlineEN.DbType =DbType.String;
                    if (obj.OutlineEN == null)
                    {
                        prmOutlineEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOutlineEN.Value = obj.OutlineEN;
                    }
                

                    


                    DbParameter prmDuration = con.createParameter();
                    prmDuration.ParameterName = "@Duration";
                    prmDuration.DbType =DbType.Int64;
                    if (obj.Duration == null)
                    {
                        prmDuration.Value = DBNull.Value;
                    }
                    else
                    {
                        prmDuration.Value = obj.Duration;
                    }
                

                    


                    DbParameter prmPath = con.createParameter();
                    prmPath.ParameterName = "@Path";
                    prmPath.DbType =DbType.String;
                    if (obj.Path == null)
                    {
                        prmPath.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPath.Value = obj.Path;
                    }
                

                    


                    DbParameter prmStatusID = con.createParameter();
                    prmStatusID.ParameterName = "@StatusID";
                    prmStatusID.DbType =DbType.Int64;
                    if (obj.StatusID == null)
                    {
                        prmStatusID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStatusID.Value = obj.StatusID;
                    }
                

                    


                    DbParameter prmObjectivesAR = con.createParameter();
                    prmObjectivesAR.ParameterName = "@ObjectivesAR";
                    prmObjectivesAR.DbType =DbType.String;
                    if (obj.ObjectivesAR == null)
                    {
                        prmObjectivesAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmObjectivesAR.Value = obj.ObjectivesAR;
                    }
                

                    


                    DbParameter prmObjectivesEN = con.createParameter();
                    prmObjectivesEN.ParameterName = "@ObjectivesEN";
                    prmObjectivesEN.DbType =DbType.String;
                    if (obj.ObjectivesEN == null)
                    {
                        prmObjectivesEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmObjectivesEN.Value = obj.ObjectivesEN;
                    }
                

                    


                    DbParameter prmisCaptivate = con.createParameter();
                    prmisCaptivate.ParameterName = "@isCaptivate";
                    prmisCaptivate.DbType =DbType.Boolean;
                    if (obj.isCaptivate == null)
                    {
                        prmisCaptivate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmisCaptivate.Value = obj.isCaptivate;
                    }
                

                    


                    DbParameter prmCaptivateFile = con.createParameter();
                    prmCaptivateFile.ParameterName = "@CaptivateFile";
                    prmCaptivateFile.DbType =DbType.String;
                    if (obj.CaptivateFile == null)
                    {
                        prmCaptivateFile.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCaptivateFile.Value = obj.CaptivateFile;
                    }
                

                    


                    DbParameter prmLanguageID = con.createParameter();
                    prmLanguageID.ParameterName = "@LanguageID";
                    prmLanguageID.DbType =DbType.Int64;
                    if (obj.LanguageID == null)
                    {
                        prmLanguageID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLanguageID.Value = obj.LanguageID;
                    }
                

                    


           



            string strQuery = " insert into dbo.[Courses] ([CourseNameEN],[CourseNameAR],[FolderID],[DateOfCreation],[TargetAR],[TargetEN],[OutlineAR],[OutlineEN],[Duration],[Path],[StatusID],[ObjectivesAR],[ObjectivesEN],[isCaptivate],[CaptivateFile],[LanguageID]) VALUES (@CourseNameEN,@CourseNameAR,@FolderID,@DateOfCreation,@TargetAR,@TargetEN,@OutlineAR,@OutlineEN,@Duration,@Path,@StatusID,@ObjectivesAR,@ObjectivesEN,@isCaptivate,@CaptivateFile,@LanguageID) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmCourseNameEN,prmCourseNameAR,prmFolderID,prmDateOfCreation,prmTargetAR,prmTargetEN,prmOutlineAR,prmOutlineEN,prmDuration,prmPath,prmStatusID,prmObjectivesAR,prmObjectivesEN,prmisCaptivate,prmCaptivateFile,prmLanguageID);


                    try
                    {
                        obj.ID = System.Int64.Parse(scope.ToString());
                    }
                    catch
                    {
                        obj.ID = -1;
                    }


                    


           

        }



        public void Insert(Courses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, Courses obj)
        {
            
            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmCourseNameEN = con.createParameter();
                    prmCourseNameEN.ParameterName = "@CourseNameEN";
                    prmCourseNameEN.DbType =DbType.String;
                    if (obj.CourseNameEN == null)
                    {
                        prmCourseNameEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCourseNameEN.Value = obj.CourseNameEN;
                    }
                

                    


                    DbParameter prmCourseNameAR = con.createParameter();
                    prmCourseNameAR.ParameterName = "@CourseNameAR";
                    prmCourseNameAR.DbType =DbType.String;
                    if (obj.CourseNameAR == null)
                    {
                        prmCourseNameAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCourseNameAR.Value = obj.CourseNameAR;
                    }
                

                    


                    DbParameter prmFolderID = con.createParameter();
                    prmFolderID.ParameterName = "@FolderID";
                    prmFolderID.DbType =DbType.Int64;
                    if (obj.FolderID == null)
                    {
                        prmFolderID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFolderID.Value = obj.FolderID;
                    }
                

                    


                    DbParameter prmDateOfCreation = con.createParameter();
                    prmDateOfCreation.ParameterName = "@DateOfCreation";
                    prmDateOfCreation.DbType =DbType.DateTime;
                    if (obj.DateOfCreation == null)
                    {
                        prmDateOfCreation.Value = DBNull.Value;
                    }
                    else
                    {
                        prmDateOfCreation.Value = obj.DateOfCreation;
                    }
                

                    


                    DbParameter prmTargetAR = con.createParameter();
                    prmTargetAR.ParameterName = "@TargetAR";
                    prmTargetAR.DbType =DbType.String;
                    if (obj.TargetAR == null)
                    {
                        prmTargetAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTargetAR.Value = obj.TargetAR;
                    }
                

                    


                    DbParameter prmTargetEN = con.createParameter();
                    prmTargetEN.ParameterName = "@TargetEN";
                    prmTargetEN.DbType =DbType.String;
                    if (obj.TargetEN == null)
                    {
                        prmTargetEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmTargetEN.Value = obj.TargetEN;
                    }
                

                    


                    DbParameter prmOutlineAR = con.createParameter();
                    prmOutlineAR.ParameterName = "@OutlineAR";
                    prmOutlineAR.DbType =DbType.String;
                    if (obj.OutlineAR == null)
                    {
                        prmOutlineAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOutlineAR.Value = obj.OutlineAR;
                    }
                

                    


                    DbParameter prmOutlineEN = con.createParameter();
                    prmOutlineEN.ParameterName = "@OutlineEN";
                    prmOutlineEN.DbType =DbType.String;
                    if (obj.OutlineEN == null)
                    {
                        prmOutlineEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmOutlineEN.Value = obj.OutlineEN;
                    }
                

                    


                    DbParameter prmDuration = con.createParameter();
                    prmDuration.ParameterName = "@Duration";
                    prmDuration.DbType =DbType.Int64;
                    if (obj.Duration == null)
                    {
                        prmDuration.Value = DBNull.Value;
                    }
                    else
                    {
                        prmDuration.Value = obj.Duration;
                    }
                

                    


                    DbParameter prmPath = con.createParameter();
                    prmPath.ParameterName = "@Path";
                    prmPath.DbType =DbType.String;
                    if (obj.Path == null)
                    {
                        prmPath.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPath.Value = obj.Path;
                    }
                

                    


                    DbParameter prmStatusID = con.createParameter();
                    prmStatusID.ParameterName = "@StatusID";
                    prmStatusID.DbType =DbType.Int64;
                    if (obj.StatusID == null)
                    {
                        prmStatusID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmStatusID.Value = obj.StatusID;
                    }
                

                    


                    DbParameter prmObjectivesAR = con.createParameter();
                    prmObjectivesAR.ParameterName = "@ObjectivesAR";
                    prmObjectivesAR.DbType =DbType.String;
                    if (obj.ObjectivesAR == null)
                    {
                        prmObjectivesAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmObjectivesAR.Value = obj.ObjectivesAR;
                    }
                

                    


                    DbParameter prmObjectivesEN = con.createParameter();
                    prmObjectivesEN.ParameterName = "@ObjectivesEN";
                    prmObjectivesEN.DbType =DbType.String;
                    if (obj.ObjectivesEN == null)
                    {
                        prmObjectivesEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmObjectivesEN.Value = obj.ObjectivesEN;
                    }
                

                    


                    DbParameter prmisCaptivate = con.createParameter();
                    prmisCaptivate.ParameterName = "@isCaptivate";
                    prmisCaptivate.DbType =DbType.Boolean;
                    if (obj.isCaptivate == null)
                    {
                        prmisCaptivate.Value = DBNull.Value;
                    }
                    else
                    {
                        prmisCaptivate.Value = obj.isCaptivate;
                    }
                

                    


                    DbParameter prmCaptivateFile = con.createParameter();
                    prmCaptivateFile.ParameterName = "@CaptivateFile";
                    prmCaptivateFile.DbType =DbType.String;
                    if (obj.CaptivateFile == null)
                    {
                        prmCaptivateFile.Value = DBNull.Value;
                    }
                    else
                    {
                        prmCaptivateFile.Value = obj.CaptivateFile;
                    }
                

                    


                    DbParameter prmLanguageID = con.createParameter();
                    prmLanguageID.ParameterName = "@LanguageID";
                    prmLanguageID.DbType =DbType.Int64;
                    if (obj.LanguageID == null)
                    {
                        prmLanguageID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmLanguageID.Value = obj.LanguageID;
                    }
                

                    


           



            string strQuery = " update dbo.[Courses] set [CourseNameEN]=@CourseNameEN,[CourseNameAR]=@CourseNameAR,[FolderID]=@FolderID,[DateOfCreation]=@DateOfCreation,[TargetAR]=@TargetAR,[TargetEN]=@TargetEN,[OutlineAR]=@OutlineAR,[OutlineEN]=@OutlineEN,[Duration]=@Duration,[Path]=@Path,[StatusID]=@StatusID,[ObjectivesAR]=@ObjectivesAR,[ObjectivesEN]=@ObjectivesEN,[isCaptivate]=@isCaptivate,[CaptivateFile]=@CaptivateFile,[LanguageID]=@LanguageID where  [ID]=@ID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmID,prmCourseNameEN,prmCourseNameAR,prmFolderID,prmDateOfCreation,prmTargetAR,prmTargetEN,prmOutlineAR,prmOutlineEN,prmDuration,prmPath,prmStatusID,prmObjectivesAR,prmObjectivesEN,prmisCaptivate,prmCaptivateFile,prmLanguageID);

            

        }


        public void Update(Courses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, Courses obj)
        {

            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[Courses]  where  [ID]=@ID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmID );  

             



        }


        public void Delete( Courses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<Courses> getCoursesByID(ClassDataHandler con,System.Int64 ID)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType = DbType.Int64;
                        if (ID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmID.Value = ID;
                        }


                        lstRet = Select(con, "" , " where [ID]=@ID ", prmID);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByID(System.Int64 ID)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByID(con, ID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByCourseNameEN(ClassDataHandler con,System.String CourseNameEN)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmCourseNameEN = con.createParameter();
                        prmCourseNameEN.ParameterName = "@CourseNameEN";
                        prmCourseNameEN.DbType = DbType.String;
                        if (CourseNameEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmCourseNameEN.Value = CourseNameEN;
                        }


                        lstRet = Select(con, "" , " where [CourseNameEN]=@CourseNameEN ", prmCourseNameEN);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByCourseNameEN(System.String CourseNameEN)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByCourseNameEN(con, CourseNameEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByCourseNameAR(ClassDataHandler con,System.String CourseNameAR)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmCourseNameAR = con.createParameter();
                        prmCourseNameAR.ParameterName = "@CourseNameAR";
                        prmCourseNameAR.DbType = DbType.String;
                        if (CourseNameAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmCourseNameAR.Value = CourseNameAR;
                        }


                        lstRet = Select(con, "" , " where [CourseNameAR]=@CourseNameAR ", prmCourseNameAR);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByCourseNameAR(System.String CourseNameAR)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByCourseNameAR(con, CourseNameAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByFolderID(ClassDataHandler con,System.Int64 FolderID)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmFolderID = con.createParameter();
                        prmFolderID.ParameterName = "@FolderID";
                        prmFolderID.DbType = DbType.Int64;
                        if (FolderID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmFolderID.Value = FolderID;
                        }


                        lstRet = Select(con, "" , " where [FolderID]=@FolderID ", prmFolderID);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByFolderID(System.Int64 FolderID)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByFolderID(con, FolderID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByDateOfCreation(ClassDataHandler con,System.DateTime? DateOfCreation)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmDateOfCreation = con.createParameter();
                        prmDateOfCreation.ParameterName = "@DateOfCreation";
                        prmDateOfCreation.DbType = DbType.DateTime;
                        if (DateOfCreation == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmDateOfCreation.Value = DateOfCreation;
                        }


                        lstRet = Select(con, "" , " where [DateOfCreation]=@DateOfCreation ", prmDateOfCreation);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByDateOfCreation(System.DateTime? DateOfCreation)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByDateOfCreation(con, DateOfCreation);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByTargetAR(ClassDataHandler con,System.String TargetAR)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmTargetAR = con.createParameter();
                        prmTargetAR.ParameterName = "@TargetAR";
                        prmTargetAR.DbType = DbType.String;
                        if (TargetAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmTargetAR.Value = TargetAR;
                        }


                        lstRet = Select(con, "" , " where [TargetAR]=@TargetAR ", prmTargetAR);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByTargetAR(System.String TargetAR)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByTargetAR(con, TargetAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByTargetEN(ClassDataHandler con,System.String TargetEN)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmTargetEN = con.createParameter();
                        prmTargetEN.ParameterName = "@TargetEN";
                        prmTargetEN.DbType = DbType.String;
                        if (TargetEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmTargetEN.Value = TargetEN;
                        }


                        lstRet = Select(con, "" , " where [TargetEN]=@TargetEN ", prmTargetEN);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByTargetEN(System.String TargetEN)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByTargetEN(con, TargetEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByOutlineAR(ClassDataHandler con,System.String OutlineAR)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmOutlineAR = con.createParameter();
                        prmOutlineAR.ParameterName = "@OutlineAR";
                        prmOutlineAR.DbType = DbType.String;
                        if (OutlineAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmOutlineAR.Value = OutlineAR;
                        }


                        lstRet = Select(con, "" , " where [OutlineAR]=@OutlineAR ", prmOutlineAR);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByOutlineAR(System.String OutlineAR)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByOutlineAR(con, OutlineAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByOutlineEN(ClassDataHandler con,System.String OutlineEN)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmOutlineEN = con.createParameter();
                        prmOutlineEN.ParameterName = "@OutlineEN";
                        prmOutlineEN.DbType = DbType.String;
                        if (OutlineEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmOutlineEN.Value = OutlineEN;
                        }


                        lstRet = Select(con, "" , " where [OutlineEN]=@OutlineEN ", prmOutlineEN);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByOutlineEN(System.String OutlineEN)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByOutlineEN(con, OutlineEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByDuration(ClassDataHandler con,System.Int64? Duration)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmDuration = con.createParameter();
                        prmDuration.ParameterName = "@Duration";
                        prmDuration.DbType = DbType.Int64;
                        if (Duration == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmDuration.Value = Duration;
                        }


                        lstRet = Select(con, "" , " where [Duration]=@Duration ", prmDuration);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByDuration(System.Int64? Duration)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByDuration(con, Duration);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByPath(ClassDataHandler con,System.String Path)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmPath = con.createParameter();
                        prmPath.ParameterName = "@Path";
                        prmPath.DbType = DbType.String;
                        if (Path == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPath.Value = Path;
                        }


                        lstRet = Select(con, "" , " where [Path]=@Path ", prmPath);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByPath(System.String Path)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByPath(con, Path);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByStatusID(ClassDataHandler con,System.Int64 StatusID)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmStatusID = con.createParameter();
                        prmStatusID.ParameterName = "@StatusID";
                        prmStatusID.DbType = DbType.Int64;
                        if (StatusID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmStatusID.Value = StatusID;
                        }


                        lstRet = Select(con, "" , " where [StatusID]=@StatusID ", prmStatusID);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByStatusID(System.Int64 StatusID)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByStatusID(con, StatusID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByObjectivesAR(ClassDataHandler con,System.String ObjectivesAR)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmObjectivesAR = con.createParameter();
                        prmObjectivesAR.ParameterName = "@ObjectivesAR";
                        prmObjectivesAR.DbType = DbType.String;
                        if (ObjectivesAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmObjectivesAR.Value = ObjectivesAR;
                        }


                        lstRet = Select(con, "" , " where [ObjectivesAR]=@ObjectivesAR ", prmObjectivesAR);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByObjectivesAR(System.String ObjectivesAR)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByObjectivesAR(con, ObjectivesAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByObjectivesEN(ClassDataHandler con,System.String ObjectivesEN)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmObjectivesEN = con.createParameter();
                        prmObjectivesEN.ParameterName = "@ObjectivesEN";
                        prmObjectivesEN.DbType = DbType.String;
                        if (ObjectivesEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmObjectivesEN.Value = ObjectivesEN;
                        }


                        lstRet = Select(con, "" , " where [ObjectivesEN]=@ObjectivesEN ", prmObjectivesEN);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByObjectivesEN(System.String ObjectivesEN)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByObjectivesEN(con, ObjectivesEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByisCaptivate(ClassDataHandler con,System.Boolean isCaptivate)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmisCaptivate = con.createParameter();
                        prmisCaptivate.ParameterName = "@isCaptivate";
                        prmisCaptivate.DbType = DbType.Boolean;
                        if (isCaptivate == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmisCaptivate.Value = isCaptivate;
                        }


                        lstRet = Select(con, "" , " where [isCaptivate]=@isCaptivate ", prmisCaptivate);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByisCaptivate(System.Boolean isCaptivate)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByisCaptivate(con, isCaptivate);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByCaptivateFile(ClassDataHandler con,System.String CaptivateFile)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmCaptivateFile = con.createParameter();
                        prmCaptivateFile.ParameterName = "@CaptivateFile";
                        prmCaptivateFile.DbType = DbType.String;
                        if (CaptivateFile == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmCaptivateFile.Value = CaptivateFile;
                        }


                        lstRet = Select(con, "" , " where [CaptivateFile]=@CaptivateFile ", prmCaptivateFile);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByCaptivateFile(System.String CaptivateFile)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByCaptivateFile(con, CaptivateFile);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Courses> getCoursesByLanguageID(ClassDataHandler con,System.Int64 LanguageID)
                    {
                        List<Courses> lstRet = new List<Courses>();


                        DbParameter prmLanguageID = con.createParameter();
                        prmLanguageID.ParameterName = "@LanguageID";
                        prmLanguageID.DbType = DbType.Int64;
                        if (LanguageID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmLanguageID.Value = LanguageID;
                        }


                        lstRet = Select(con, "" , " where [LanguageID]=@LanguageID ", prmLanguageID);



                        return lstRet;

                    }


                    public List<Courses> getCoursesByLanguageID(System.Int64 LanguageID)
                    {
                        List<Courses> lstRet = new List<Courses>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getCoursesByLanguageID(con, LanguageID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<Courses> Search(ClassDataHandler con, Courses obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID AND ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.CourseNameEN != "")
                    {
                        DbParameter prmCourseNameEN = con.createParameter();
                        prmCourseNameEN.ParameterName = "@CourseNameEN";
                        prmCourseNameEN.DbType =DbType.String;
                        if (obj.CourseNameEN == null)
                        {
                            prmCourseNameEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCourseNameEN.Value = obj.CourseNameEN;
                        }
                        strWhere += " [CourseNameEN]=@CourseNameEN AND ";
                        lstParameters.Add(prmCourseNameEN);
                     }



                    

                    if (obj.CourseNameAR != "")
                    {
                        DbParameter prmCourseNameAR = con.createParameter();
                        prmCourseNameAR.ParameterName = "@CourseNameAR";
                        prmCourseNameAR.DbType =DbType.String;
                        if (obj.CourseNameAR == null)
                        {
                            prmCourseNameAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCourseNameAR.Value = obj.CourseNameAR;
                        }
                        strWhere += " [CourseNameAR]=@CourseNameAR AND ";
                        lstParameters.Add(prmCourseNameAR);
                     }



                    

                    if (obj.FolderID != -1)
                    {
                        DbParameter prmFolderID = con.createParameter();
                        prmFolderID.ParameterName = "@FolderID";
                        prmFolderID.DbType =DbType.Int64;
                        if (obj.FolderID == null)
                        {
                            prmFolderID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFolderID.Value = obj.FolderID;
                        }
                        strWhere += " [FolderID]=@FolderID AND ";
                        lstParameters.Add(prmFolderID);
                     }



                    

                    if (obj.DateOfCreation != null)
                    {
                        DbParameter prmDateOfCreation = con.createParameter();
                        prmDateOfCreation.ParameterName = "@DateOfCreation";
                        prmDateOfCreation.DbType =DbType.DateTime;
                        if (obj.DateOfCreation == null)
                        {
                            prmDateOfCreation.Value = DBNull.Value;
                        }
                        else
                        {
                            prmDateOfCreation.Value = obj.DateOfCreation;
                        }
                        strWhere += " [DateOfCreation]=@DateOfCreation AND ";
                        lstParameters.Add(prmDateOfCreation);
                     }



                    

                    if (obj.TargetAR != "")
                    {
                        DbParameter prmTargetAR = con.createParameter();
                        prmTargetAR.ParameterName = "@TargetAR";
                        prmTargetAR.DbType =DbType.String;
                        if (obj.TargetAR == null)
                        {
                            prmTargetAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTargetAR.Value = obj.TargetAR;
                        }
                        strWhere += " [TargetAR]=@TargetAR AND ";
                        lstParameters.Add(prmTargetAR);
                     }



                    

                    if (obj.TargetEN != "")
                    {
                        DbParameter prmTargetEN = con.createParameter();
                        prmTargetEN.ParameterName = "@TargetEN";
                        prmTargetEN.DbType =DbType.String;
                        if (obj.TargetEN == null)
                        {
                            prmTargetEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTargetEN.Value = obj.TargetEN;
                        }
                        strWhere += " [TargetEN]=@TargetEN AND ";
                        lstParameters.Add(prmTargetEN);
                     }



                    

                    if (obj.OutlineAR != "")
                    {
                        DbParameter prmOutlineAR = con.createParameter();
                        prmOutlineAR.ParameterName = "@OutlineAR";
                        prmOutlineAR.DbType =DbType.String;
                        if (obj.OutlineAR == null)
                        {
                            prmOutlineAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOutlineAR.Value = obj.OutlineAR;
                        }
                        strWhere += " [OutlineAR]=@OutlineAR AND ";
                        lstParameters.Add(prmOutlineAR);
                     }



                    

                    if (obj.OutlineEN != "")
                    {
                        DbParameter prmOutlineEN = con.createParameter();
                        prmOutlineEN.ParameterName = "@OutlineEN";
                        prmOutlineEN.DbType =DbType.String;
                        if (obj.OutlineEN == null)
                        {
                            prmOutlineEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOutlineEN.Value = obj.OutlineEN;
                        }
                        strWhere += " [OutlineEN]=@OutlineEN AND ";
                        lstParameters.Add(prmOutlineEN);
                     }



                    

                    if (obj.Duration != null)
                    {
                        DbParameter prmDuration = con.createParameter();
                        prmDuration.ParameterName = "@Duration";
                        prmDuration.DbType =DbType.Int64;
                        if (obj.Duration == null)
                        {
                            prmDuration.Value = DBNull.Value;
                        }
                        else
                        {
                            prmDuration.Value = obj.Duration;
                        }
                        strWhere += " [Duration]=@Duration AND ";
                        lstParameters.Add(prmDuration);
                     }



                    

                    if (obj.Path != "")
                    {
                        DbParameter prmPath = con.createParameter();
                        prmPath.ParameterName = "@Path";
                        prmPath.DbType =DbType.String;
                        if (obj.Path == null)
                        {
                            prmPath.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPath.Value = obj.Path;
                        }
                        strWhere += " [Path]=@Path AND ";
                        lstParameters.Add(prmPath);
                     }



                    

                    if (obj.StatusID != -1)
                    {
                        DbParameter prmStatusID = con.createParameter();
                        prmStatusID.ParameterName = "@StatusID";
                        prmStatusID.DbType =DbType.Int64;
                        if (obj.StatusID == null)
                        {
                            prmStatusID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStatusID.Value = obj.StatusID;
                        }
                        strWhere += " [StatusID]=@StatusID AND ";
                        lstParameters.Add(prmStatusID);
                     }



                    

                    if (obj.ObjectivesAR != null)
                    {
                        DbParameter prmObjectivesAR = con.createParameter();
                        prmObjectivesAR.ParameterName = "@ObjectivesAR";
                        prmObjectivesAR.DbType =DbType.String;
                        if (obj.ObjectivesAR == null)
                        {
                            prmObjectivesAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmObjectivesAR.Value = obj.ObjectivesAR;
                        }
                        strWhere += " [ObjectivesAR]=@ObjectivesAR AND ";
                        lstParameters.Add(prmObjectivesAR);
                     }



                    

                    if (obj.ObjectivesEN != null)
                    {
                        DbParameter prmObjectivesEN = con.createParameter();
                        prmObjectivesEN.ParameterName = "@ObjectivesEN";
                        prmObjectivesEN.DbType =DbType.String;
                        if (obj.ObjectivesEN == null)
                        {
                            prmObjectivesEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmObjectivesEN.Value = obj.ObjectivesEN;
                        }
                        strWhere += " [ObjectivesEN]=@ObjectivesEN AND ";
                        lstParameters.Add(prmObjectivesEN);
                     }



                    

                    if (obj.isCaptivate != false)
                    {
                        DbParameter prmisCaptivate = con.createParameter();
                        prmisCaptivate.ParameterName = "@isCaptivate";
                        prmisCaptivate.DbType =DbType.Boolean;
                        if (obj.isCaptivate == null)
                        {
                            prmisCaptivate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmisCaptivate.Value = obj.isCaptivate;
                        }
                        strWhere += " [isCaptivate]=@isCaptivate AND ";
                        lstParameters.Add(prmisCaptivate);
                     }



                    

                    if (obj.CaptivateFile != "")
                    {
                        DbParameter prmCaptivateFile = con.createParameter();
                        prmCaptivateFile.ParameterName = "@CaptivateFile";
                        prmCaptivateFile.DbType =DbType.String;
                        if (obj.CaptivateFile == null)
                        {
                            prmCaptivateFile.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCaptivateFile.Value = obj.CaptivateFile;
                        }
                        strWhere += " [CaptivateFile]=@CaptivateFile AND ";
                        lstParameters.Add(prmCaptivateFile);
                     }



                    

                    if (obj.LanguageID != -1)
                    {
                        DbParameter prmLanguageID = con.createParameter();
                        prmLanguageID.ParameterName = "@LanguageID";
                        prmLanguageID.DbType =DbType.Int64;
                        if (obj.LanguageID == null)
                        {
                            prmLanguageID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLanguageID.Value = obj.LanguageID;
                        }
                        strWhere += " [LanguageID]=@LanguageID AND ";
                        lstParameters.Add(prmLanguageID);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<Courses> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<Courses> Search(Courses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Courses> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<Courses> SearchOrLike(ClassDataHandler con, Courses obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID OR ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.CourseNameEN != "")
                    {
                        DbParameter prmCourseNameEN = con.createParameter();
                        prmCourseNameEN.ParameterName = "@CourseNameEN";
                        prmCourseNameEN.DbType =DbType.String;
                        if (obj.CourseNameEN == null)
                        {
                            prmCourseNameEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCourseNameEN.Value = obj.CourseNameEN;
                        }
                        strWhere += " [CourseNameEN] LIKE @CourseNameEN OR ";
                        lstParameters.Add(prmCourseNameEN);
                     }



                    

                    if (obj.CourseNameAR != "")
                    {
                        DbParameter prmCourseNameAR = con.createParameter();
                        prmCourseNameAR.ParameterName = "@CourseNameAR";
                        prmCourseNameAR.DbType =DbType.String;
                        if (obj.CourseNameAR == null)
                        {
                            prmCourseNameAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCourseNameAR.Value = obj.CourseNameAR;
                        }
                        strWhere += " [CourseNameAR] LIKE @CourseNameAR OR ";
                        lstParameters.Add(prmCourseNameAR);
                     }



                    

                    if (obj.FolderID != -1)
                    {
                        DbParameter prmFolderID = con.createParameter();
                        prmFolderID.ParameterName = "@FolderID";
                        prmFolderID.DbType =DbType.Int64;
                        if (obj.FolderID == null)
                        {
                            prmFolderID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFolderID.Value = obj.FolderID;
                        }
                        strWhere += " [FolderID]=@FolderID OR ";
                        lstParameters.Add(prmFolderID);
                     }



                    

                    if (obj.DateOfCreation != null)
                    {
                        DbParameter prmDateOfCreation = con.createParameter();
                        prmDateOfCreation.ParameterName = "@DateOfCreation";
                        prmDateOfCreation.DbType =DbType.DateTime;
                        if (obj.DateOfCreation == null)
                        {
                            prmDateOfCreation.Value = DBNull.Value;
                        }
                        else
                        {
                            prmDateOfCreation.Value = obj.DateOfCreation;
                        }
                        strWhere += " [DateOfCreation]=@DateOfCreation OR ";
                        lstParameters.Add(prmDateOfCreation);
                     }



                    

                    if (obj.TargetAR != "")
                    {
                        DbParameter prmTargetAR = con.createParameter();
                        prmTargetAR.ParameterName = "@TargetAR";
                        prmTargetAR.DbType =DbType.String;
                        if (obj.TargetAR == null)
                        {
                            prmTargetAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTargetAR.Value = obj.TargetAR;
                        }
                        strWhere += " [TargetAR] LIKE @TargetAR OR ";
                        lstParameters.Add(prmTargetAR);
                     }



                    

                    if (obj.TargetEN != "")
                    {
                        DbParameter prmTargetEN = con.createParameter();
                        prmTargetEN.ParameterName = "@TargetEN";
                        prmTargetEN.DbType =DbType.String;
                        if (obj.TargetEN == null)
                        {
                            prmTargetEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmTargetEN.Value = obj.TargetEN;
                        }
                        strWhere += " [TargetEN] LIKE @TargetEN OR ";
                        lstParameters.Add(prmTargetEN);
                     }



                    

                    if (obj.OutlineAR != "")
                    {
                        DbParameter prmOutlineAR = con.createParameter();
                        prmOutlineAR.ParameterName = "@OutlineAR";
                        prmOutlineAR.DbType =DbType.String;
                        if (obj.OutlineAR == null)
                        {
                            prmOutlineAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOutlineAR.Value = obj.OutlineAR;
                        }
                        strWhere += " [OutlineAR] LIKE @OutlineAR OR ";
                        lstParameters.Add(prmOutlineAR);
                     }



                    

                    if (obj.OutlineEN != "")
                    {
                        DbParameter prmOutlineEN = con.createParameter();
                        prmOutlineEN.ParameterName = "@OutlineEN";
                        prmOutlineEN.DbType =DbType.String;
                        if (obj.OutlineEN == null)
                        {
                            prmOutlineEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmOutlineEN.Value = obj.OutlineEN;
                        }
                        strWhere += " [OutlineEN] LIKE @OutlineEN OR ";
                        lstParameters.Add(prmOutlineEN);
                     }



                    

                    if (obj.Duration != null)
                    {
                        DbParameter prmDuration = con.createParameter();
                        prmDuration.ParameterName = "@Duration";
                        prmDuration.DbType =DbType.Int64;
                        if (obj.Duration == null)
                        {
                            prmDuration.Value = DBNull.Value;
                        }
                        else
                        {
                            prmDuration.Value = obj.Duration;
                        }
                        strWhere += " [Duration]=@Duration OR ";
                        lstParameters.Add(prmDuration);
                     }



                    

                    if (obj.Path != "")
                    {
                        DbParameter prmPath = con.createParameter();
                        prmPath.ParameterName = "@Path";
                        prmPath.DbType =DbType.String;
                        if (obj.Path == null)
                        {
                            prmPath.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPath.Value = obj.Path;
                        }
                        strWhere += " [Path] LIKE @Path OR ";
                        lstParameters.Add(prmPath);
                     }



                    

                    if (obj.StatusID != -1)
                    {
                        DbParameter prmStatusID = con.createParameter();
                        prmStatusID.ParameterName = "@StatusID";
                        prmStatusID.DbType =DbType.Int64;
                        if (obj.StatusID == null)
                        {
                            prmStatusID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmStatusID.Value = obj.StatusID;
                        }
                        strWhere += " [StatusID]=@StatusID OR ";
                        lstParameters.Add(prmStatusID);
                     }



                    

                    if (obj.ObjectivesAR != null)
                    {
                        DbParameter prmObjectivesAR = con.createParameter();
                        prmObjectivesAR.ParameterName = "@ObjectivesAR";
                        prmObjectivesAR.DbType =DbType.String;
                        if (obj.ObjectivesAR == null)
                        {
                            prmObjectivesAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmObjectivesAR.Value = obj.ObjectivesAR;
                        }
                        strWhere += " [ObjectivesAR] LIKE @ObjectivesAR OR ";
                        lstParameters.Add(prmObjectivesAR);
                     }



                    

                    if (obj.ObjectivesEN != null)
                    {
                        DbParameter prmObjectivesEN = con.createParameter();
                        prmObjectivesEN.ParameterName = "@ObjectivesEN";
                        prmObjectivesEN.DbType =DbType.String;
                        if (obj.ObjectivesEN == null)
                        {
                            prmObjectivesEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmObjectivesEN.Value = obj.ObjectivesEN;
                        }
                        strWhere += " [ObjectivesEN] LIKE @ObjectivesEN OR ";
                        lstParameters.Add(prmObjectivesEN);
                     }



                    

                    if (obj.isCaptivate != false)
                    {
                        DbParameter prmisCaptivate = con.createParameter();
                        prmisCaptivate.ParameterName = "@isCaptivate";
                        prmisCaptivate.DbType =DbType.Boolean;
                        if (obj.isCaptivate == null)
                        {
                            prmisCaptivate.Value = DBNull.Value;
                        }
                        else
                        {
                            prmisCaptivate.Value = obj.isCaptivate;
                        }
                        strWhere += " [isCaptivate]=@isCaptivate OR ";
                        lstParameters.Add(prmisCaptivate);
                     }



                    

                    if (obj.CaptivateFile != "")
                    {
                        DbParameter prmCaptivateFile = con.createParameter();
                        prmCaptivateFile.ParameterName = "@CaptivateFile";
                        prmCaptivateFile.DbType =DbType.String;
                        if (obj.CaptivateFile == null)
                        {
                            prmCaptivateFile.Value = DBNull.Value;
                        }
                        else
                        {
                            prmCaptivateFile.Value = obj.CaptivateFile;
                        }
                        strWhere += " [CaptivateFile] LIKE @CaptivateFile OR ";
                        lstParameters.Add(prmCaptivateFile);
                     }



                    

                    if (obj.LanguageID != -1)
                    {
                        DbParameter prmLanguageID = con.createParameter();
                        prmLanguageID.ParameterName = "@LanguageID";
                        prmLanguageID.DbType =DbType.Int64;
                        if (obj.LanguageID == null)
                        {
                            prmLanguageID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmLanguageID.Value = obj.LanguageID;
                        }
                        strWhere += " [LanguageID]=@LanguageID OR ";
                        lstParameters.Add(prmLanguageID);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<Courses> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<Courses> SearchOrLike(Courses obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Courses> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            